package com.service.setting.impl;

import com.comm.R;
import com.entity.AdministrativeOffice;
import com.entity.Menu;
import com.mapper.setting.SysDutyMapper;
import com.service.setting.SysDutyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class SysDutyServiceImpl implements SysDutyService {

    @Autowired
    private SysDutyMapper sysDutyMapper;


    //点击查询职务表所有信息
    @Override
    public R findDutyList() {

        R r = new R();

        try {
            List<AdministrativeOffice> dutyList = sysDutyMapper.findDutyList();
            if(dutyList!=null){
                r.setCode(200);
                r.setMsg("查询成功");
                r.setData(dutyList);
            }else{
                r.setCode(500);
                r.setMsg("没有数据,查询失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            r.setCode(500);
            r.setMsg("系统出现故障了哦");
        }

        return r;
    }


    //根据角色id查看所拥有权限
    @Override
    public R findMenuByRoleId(Integer id) {
        R r = new R();

        try {
            List<Menu> menuList = sysDutyMapper.findMenuByRoleId(id);

            if(menuList!=null){
                r.setCode(200);
                r.setMsg("查询成功");
                r.setData(menuList);
            }else{
                r.setCode(500);
                r.setMsg("查询失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            r.setCode(500);
            r.setMsg("系统出现故障!!!");
        }
        return r;
    }
}
